package com.qezhhnjy.firstuser.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.context.annotation.Configuration;

/**
 * @author zhaoyangfu
 * @date 2021/5/18-19:22
 */
@Aspect
@Configuration
@Slf4j
public class Aop {

    @Pointcut("execution(public * com.qezhhnjy.firstuser.bean.MyTestBean.*(..))")
    public void pointCut() {

    }

    @Around("pointCut()")
    public Object around(ProceedingJoinPoint point) throws Throwable {
        log.warn("point=>{}", point);
        log.warn("point=>{}", point.getClass());
        Object proceed = point.proceed();
        log.warn("proceed=>{}", proceed);
        return proceed;
    }

    @Before("pointCut()")
    public void before(JoinPoint point) {
        log.info("before=>{}", point.getClass().toString());
    }

    @After("pointCut()")
    public void after(JoinPoint point) {
        log.info("after=>{}", point.getClass().toString());
    }

    @AfterReturning("pointCut()")
    public void returning(JoinPoint point) {
        log.info("returning=>{}", point.getClass().toString());
    }

    @AfterThrowing("pointCut()")
    public void throwing(JoinPoint point) {
        log.info("throwing=>{}", point.getClass().toString());
    }
}
